package com.sky.controller.user;


import com.sky.result.Result;
import com.sky.service.user.UserDishService;
import com.sky.vo.DishVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@EnableCaching
@RestController
@RequestMapping("/user/dish")
public class UserDishController {
    @Autowired
    private UserDishService userDishService;


    /**
     * 根据分类id查询菜品
     */
    @Cacheable(value = "dish_",key = "#categoryId")
    @ApiOperation("根据分类id查询菜品")
    @GetMapping("/list")
    public Result<List<DishVO>> selectDishVo(Integer categoryId) {

        List<DishVO> dishVOS = userDishService.selectDish(categoryId);
        return Result.success(dishVOS);

    }


}
